<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('approval_nodes', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('company_id')->default(0)->index();
            $table->unsignedBigInteger('flow_id')->comment('所属流程ID');
            $table->foreignId('role_id')->comment('审批角色ID');
            $table->unsignedBigInteger('admin_id')->comment('审批人ID');
            $table->string('name', 50)->comment('节点名称：如部门经理审批、总经理审批');
            $table->integer('sort')->default(0)->comment('节点排序，数字越小越靠前');
            $table->tinyInteger('type')->default(1)->comment('节点类型：1-普通审批 2-条件审批 3-会签 4-或签');
            $table->string('condition')->nullable()->comment('条件表达式，仅条件审批使用');
            $table->boolean('is_final')->default(false)->comment('是否最终节点');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('approval_nodes');
    }
};
